package cn.goktech.sports.modules.contentManage.controller;

import cn.goktech.sports.common.annotation.RestAnon;
import cn.goktech.sports.common.entity.Page;
import cn.goktech.sports.common.entity.R;
import cn.goktech.sports.modules.contentManage.entity.BusinessTypeEntity;
import cn.goktech.sports.modules.contentManage.service.BusinessTypeService;
import cn.goktech.sports.modules.sys.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 内容分类表
 *
 * @author duanyu<>
 */
@RestController
@RequestMapping("/rest/business/type")
public class BusinessTypeController extends AbstractController {

	@Autowired
	private BusinessTypeService businessTypeService;

	/**
	 * 根据内容分类id获取业务类型
	 *
	 * @param contentId
	 * @return
	 */
	@GetMapping("/list")
	@RestAnon
	public R list(@RequestParam Long contentId) {
		return businessTypeService.listByContentId(contentId);
	}

	/**
	 * pc端业务类型列表
	 *
	 * @param params
	 * @return
	 */
	@PostMapping("/list")
	@RestAnon
	public Page<BusinessTypeEntity> list(@RequestBody Map<String, Object> params) {
		return businessTypeService.listBusinessType(params);
	}

	@PostMapping("/save")
	@RestAnon
	public R add(@RequestBody BusinessTypeEntity entity){
		return businessTypeService.saveBusinessType(entity);
	}

	@PostMapping("/remove")
	@RestAnon
	public R remove(@RequestBody Long[] ids){
		return businessTypeService.batchRemove(ids);
	}

	/**
	 * 根据id查询详情
	 *
	 * @param id
	 * @return
	 */
	@GetMapping("/info")
	@RestAnon
	public R getById(@RequestParam("id") Long id) {
		return businessTypeService.getBusinessTypeById(id);
	}

	/**
	 * 修改
	 *
	 * @param message
	 * @return
	 */
	@RequestMapping("/update")
	@RestAnon
	public R update(@RequestBody BusinessTypeEntity entity) {
		return businessTypeService.updateBusinessType(entity);
	}
}
